From b2e5a125ae8bf682b0d54d925ce8fdf26680b48e Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Tue, 6 May 2025 02:40:18 +0200 Subject: [PATCH] breakManager: Use uninhibitable idle watch If we use a regular idle watch, any session inhibitors can prevent the watch from triggering, leading to the break manager to never consider the break as having been completed until the inhibitor is gone. This could lead to situations in which the system appears to be stuck with a dimmed screen. Also start the idle time when the idle watch is created, otherwise any previous idle time would count towards it, causing the watch to trigger early, leaving it inconsistent with the rest of the break manager state. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8378 Part-of: --- js/misc/breakManager.js | 6 +++++- tests/unit/breakManager.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/misc/breakManager.js b/js/misc/breakManager.js index a72b9c109..c90e0a9d5 100644 --- a/js/misc/breakManager.js +++ b/js/misc/breakManager.js @@ -26,6 +26,7 @@ import Cogl from 'gi://Cogl'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; @@ -194,7 +195,10 @@ export const BreakManager = GObject.registerClass({ } _startStateMachine() { - this._idleWatchId = this._idleMonitor.add_idle_watch(MIN_BREAK_LENGTH_SECONDS * 1000, this._onIdleWatch.bind(this)); + this._idleWatchId = this._idleMonitor.add_idle_watch_full( + MIN_BREAK_LENGTH_SECONDS * 1000, + this._onIdleWatch.bind(this), + Meta.IdleMonitorWatchFlags.UNINHIBITABLE | Meta.IdleMonitorWatchFlags.START_NOW); this._state = BreakState.ACTIVE; this._currentBreakType = null; diff --git a/tests/unit/breakManager.js b/tests/unit/breakManager.js index e74477696..96d6c6048 100644 --- a/tests/unit/breakManager.js +++ b/tests/unit/breakManager.js @@ -209,7 +209,7 @@ class TestHarness { // simulated clock and event queue. get mockIdleMonitor() { return { - add_idle_watch: (waitMsec, callback) => { + add_idle_watch_full: (waitMsec, callback, _flags) => { console.assert(this._idleWatch === null); this._idleWatch = { waitMsec, -- 2.39.5